﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using QzEbook.Admin;
using QzEbook.Common.Emum;
using QzEbook.Common;

public partial class admin_module_login : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void loginBtn_Click(object sender, EventArgs e)
    {
        string name = nameTb.Text.Trim();
        string pwd = pwdTb.Text.Trim();
        if (name.Length < 2 || pwd.Length < 2)
        {
            return;
        }
        SessionUser userSession = new SessionUser();
        string ip = Request.UserHostAddress;
        LoginAction action = userSession.login(name, pwd, ip);

        if (action == LoginAction.Success)
        {
            SessionManager.LoginUser = userSession;

            if (string.IsNullOrEmpty(Request["raw"]))
            {
                Response.Redirect("UserPane.xhtml");
            }
            else
            {
                Response.Redirect(Server.UrlDecode(Request["raw"]),true);
            }
        }

        status.Text = action.ToString();
    }
}